var exec=require("child_process").exec;

function start(res){
  console.log("REQUESTHANDLERS.JS:request handler 'start' was called");
/*   
  function sleep(milliSeconds){
    var startTime=new Date().getTime();
    while(new Date().getTime()<startTime+milliSeconds);*/

  //以下内容是测试10s载入不会阻塞
  exec("find /",{timeout:10000,maxBuffer:20000*1024},function(error,stdout,stderr){
    res.writeHead(200,{"Content-Type":"text/plain"});
  	res.write(stdout);
  	res.end();
  });
  //非阻塞操作 
/* exec("ls -lah", function (error, stdout, stderr) {
    res.writeHead(200, {"Content-Type": "text/plain"});
    res.write(stdout);
    res.end();
  });*/
}
  
/*  sleep(1000);
  return "Hello start";*/

function upload(res){
  console.log("REQUESTHANDLERS.JS:request handler 'upload' was called");
  res.writeHead(200,{"Content-Type":"text/plain"});
  res.write("Hello world");
  res.end();
}

exports.start=start;
exports.upload=upload;
